GBML manual / Link Cable

link_connected

True while at least one other console is playing with this one. It turns true shortly after both consoles have called link_start(), and false again if no message has arrived for half a second - the cable was pulled, the other console was switched off, or it left the two-player part of the game.

Works differently on Game Boy - The Game Boy link cable joins two consoles, not four: players 3 and 4 are never there and read as not pressing anything, and the two consoles decide between themselves which one is player 1, so it can be a different one each time they meet.

Works differently on Game Boy Color - The Game Boy Color link cable joins two consoles, not four: players 3 and 4 are never there and read as not pressing anything, and the two consoles decide between themselves which one is player 1, so it can be a different one each time they meet.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

link_connected() -> bool

Returns

bool

Description

True while at least one other console is playing with this one.

It is false until another console has been heard from, which takes a moment after both consoles have called link_start. It turns false again if nothing has been heard from every other console for 30 frames, half a second: the cable was pulled, the other console was switched off, or it left the two-player part of the game.

Ask this before you trust anything else in the group. While it is false, link_player is 0 and every link_button_* answer is "no".

Example

if (!link_connected()) {
    draw_text(12, 56, "WAITING FOR THE OTHER PLAYER");
}

Draws a waiting message whenever nobody else is on the cable, which is also what a player with no cable sees.

On the GBA

A console only knows someone is there because they keep talking: every console sends a message every frame, even when no button is down. So a quiet player is still connected, and a gone player is noticed after 30 frames. Ask this before you trust anything else in this group - while it is false, link_player() is 0 and every link_button_* is false.

See also: link_startlink_playerslink_playerThe link cable